package com.example.photography.fragment.product;

import androidx.core.view.ViewCompat;

import com.alibaba.fastjson.JSONObject;
import com.example.photography.R;
import com.example.photography.adapter.product.MyContestAdapter;
import com.example.photography.bean.MyContestBean;
import com.example.photography.common.BaseFragment;
import com.example.photography.view.MyListView;
import com.loopj.android.http.RequestParams;

import java.util.Objects;

import butterknife.BindView;

import static com.example.photography.util.Util.getJson;

/**
 * 圈子
 */
public class My_Contest extends BaseFragment {

    @BindView(R.id.lv_item)
    MyListView lvItem;
    private MyContestBean myContestBean;

    @Override
    protected RequestParams getParams() {
        return null;
    }

    @Override
    protected String getUrl() {
        return null;
    }

    @Override
    protected void initData(String content) {
        //CollapsingToolbarLayout展开/折叠
        ViewCompat.setNestedScrollingEnabled(lvItem,true);
        String json = getJson(Objects.requireNonNull(getActivity()), "my_contest.json");
        if (!json.isEmpty()) {
            myContestBean = JSONObject.parseObject(json, MyContestBean.class);
        }
        MyContestAdapter myContestAdapter = new MyContestAdapter(myContestBean.getData().getContest(),getActivity());
        lvItem.setAdapter(myContestAdapter);
    }

    @Override
    public int getLayoutId() {
        return R.layout.lv_listview;
    }
}
